package com.risk.kernel.service.impl;

import com.risk.common.utils.DateUtils;
import com.risk.kernel.domain.TkCommonDbConfig;
import com.risk.kernel.mapper.TkCommonDbConfigMapper;
import com.risk.kernel.service.TkCommonDbConfigServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Liwen
 * @createTime: 2024/12/31
 * @description:
 */
@Service
public class TkCommonDbConfigServiceImpl implements TkCommonDbConfigServiceI {
    @Autowired
    private TkCommonDbConfigMapper tkCommonDbConfigMapper;

    /**
     * 查询
     *
     * @param id 主键
     * @return
     */
    @Override
    public TkCommonDbConfig selectTkCommonDbConfigById(Long id) {
        return tkCommonDbConfigMapper.selectTkCommonDbConfigById(id);
    }

    /**
     * 查询列表
     *
     * @param tkCommonDbConfig
     * @return
     */
    @Override
    public List<TkCommonDbConfig> selectTkCommonDbConfigList(String keys) {
        return tkCommonDbConfigMapper.selectTkCommonDbConfigList(keys);
    }

    /**
     * 新增
     *
     * @param tkCommonDbConfig
     * @return 结果
     */
    @Override
    public int insertTkCommonDbConfig(TkCommonDbConfig tkCommonDbConfig) {
        tkCommonDbConfig.setCreateTime(DateUtils.getNowDate());
        return tkCommonDbConfigMapper.insertTkCommonDbConfig(tkCommonDbConfig);
    }

    /**
     * 修改
     *
     * @param tkCommonDbConfig
     * @return 结果
     */
    @Override
    public int updateTkCommonDbConfig(TkCommonDbConfig tkCommonDbConfig) {
        return tkCommonDbConfigMapper.updateTkCommonDbConfig(tkCommonDbConfig);
    }

    /**
     * 批量删除
     *
     * @param ids 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteTkCommonDbConfigByIds(Long[] ids) {
        return tkCommonDbConfigMapper.deleteTkCommonDbConfigByIds(ids);
    }

    /**
     * 删除
     *
     * @param id 主键
     * @return 结果
     */
    @Override
    public int deleteTkCommonDbConfigById(Long id) {
        return tkCommonDbConfigMapper.deleteTkCommonDbConfigById(id);
    }

    /**
     * 根据库名查询一个实体
     */
    public TkCommonDbConfig selectDbConfigByDbName(String dbName, String type){
        return tkCommonDbConfigMapper.selectDbConfigByDbName(dbName,type);
    }
}
